# -*- coding: utf-8 -*-
import HwTestReport
import time
import unittest
import sys
sys.path.append('E:\\xyz\\.jenkins\\workspace\\yui_crm')
from crm.webtest.customerassign.ctes_customerassign import TestCustomerAssign
from crm.webtest.customerassign.ctes_customerassign_all import TestCustomerAssignAll
from crm.webtest.user.ctes_login_error import TestLoginError
from crm.base.crm_use_browser import UseBrowser
from crm.webpage.login_page import LoginPage


class TestLogin(unittest.TestCase):

    # 前置条件
    def setUp(self) -> None:
        self.lp = LoginPage()

    # 登录，正确
    def test_login_success(self):
        self.lp.login(self.lp.exl.get_cell(1, 2), self.lp.exl.get_cell(1, 3))
        text = self.lp.login_suc_info()
        self.assertIn(self.lp.exl.get_cell(1, 4), text)

    # 退出
    def tearDown(self) -> None:
        UseBrowser.driver.quit()


if __name__ == '__main__':
    # unittest.main()
    suite = unittest.TestSuite()  # 实例化
    test_login = unittest.TestLoader().loadTestsFromTestCase(TestLogin)
    test_login_error = unittest.TestLoader().loadTestsFromTestCase(TestLoginError)
    test_custass = unittest.TestLoader().loadTestsFromTestCase(TestCustomerAssign)
    test_custass_all = unittest.TestLoader().loadTestsFromTestCase(TestCustomerAssignAll)

    suite.addTests([test_login, test_login_error,test_custass,test_custass_all])

    c_time = time.strftime('%Y-%m-%d_%H_%M', time.localtime())
    with open('../../report/index_report.html', 'wb+') as fp:
        runner = HwTestReport.HTMLTestReport(stream=fp, verbosity=2, title='测试结果', description='CRM房地产客户关系管理系统,客户分配')
        runner.run(suite)
